<?php

namespace app\model\zs;

use think\Model;

class ZsMemberCoupon extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'member_coupon';

    // 设置当前模型的数据库连接
    protected $connection = 'zs';

    // 领取状态，0正常，1不可领取
    const RECEIVE_STATUS_ON = 0;
    const RECEIVE_STATUS_OFF = 1;

    // 0：审核未通过 1：审核中 2：审核通过
    const STATUS_FAIL = 0;
    const STATUS_WAIT = 1;
    const STATUS_PASS = 2;

    const IS_KC_ON = 1;
    const IS_KC_OFF = 2;

    const TYPE_DEFAULT = 0;
    const TYPE_SUB_COUPON = 3;

    /**
     * 是否科传对应文字
     */
    public static function isKcRels()
    {
        return [
            self::IS_KC_ON => '是',
            self::IS_KC_OFF => '否',
        ];
    }

    public function zsBusiness()
    {
        return $this->belongsTo(ZsBusiness::class, 'bid', 'id');
    }

    // TODO:这个有问题，withCount调用会报错
    public function zsMemberCouponProvides()
    {
        return $this->hasMany(ZsMemberCouponProvide::class, 'tid', 'tid');
    }
}
